package com.threeti.mecool.core.infrastructure.persistence.plan;

import java.util.Date;
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import com.threeti.mecool.core.domain.model.plan.pojo.Plan;

public interface PlanRepository extends JpaRepository<Plan, Long>, JpaSpecificationExecutor<Plan> {
    Plan findByUserLoginNameAndPlanDateAndTypeIsNull(String userLoginName, Date planDate);

    Page<Plan> findByUserLoginName(String userLoginName, Pageable pageable);
    
    Page<Plan> findByUserLoginNameAndStatus(String userLoginName, Pageable pageable,String status);

    List<Plan> findByUserLoginName(String userLoginName);
    
    List<Plan> findByUserLoginNameAndStatus(String userLoginName,String status);

    Plan findByUserLoginNameAndPlanDateAndType(String userLoginName, Date planDate, String typeAssignment);

    Page<Plan> findByUserLoginNameInOrderByPlanDateDesc(List<String> userLoginName, Pageable pageable);

    Page<Plan> findByUserLoginNameInAndStatusOrderByPlanDateDesc(List<String> userLoginNames, String status, Pageable pageable);

    Page<Plan> findByUserLoginNameInAndPlanProjects_ProjectCodeInOrderByPlanDateDesc(List<String> userLoginNames, List<String> projectCodes, Pageable pageable);

    Page<Plan> findByUserLoginNameInAndStatusAndPlanProjects_ProjectCodeIn(List<String> userLoginNames, String status, List<String> projectCodes, Pageable pageable);
}
